<template>
    <div class="ts-text">
        <h1>{{ form.name }}</h1>
        <h4 v-if="form.subtitle">{{ form.subtitle }}</h4>
        <div class="channel">{{ form.effectDateTime }}</div>
        <div class="content" v-html="form.remark"></div>
        <div v-for="item in dataList" :key="item.id" style="font-size: 15px; margin-top: 10px;">
           附件：<span class="link-type" @click="operClick(item)">{{ item.fileName }}</span>
        </div>
    </div>
</template>
<script setup>
import { reactive, ref, onMounted } from 'vue';
import { useRoute } from 'vue-router'
import Api from '@/api/model/system'
import authApi from '@/api/model/auth.js'
import store from '@/store/index.js'
const emit = defineEmits(['updatetable'])
const route = useRoute()
// 添加用户数据的对象
const form = ref({
});
const props = defineProps({
    paramsData: {
        type: Object,
        defalut: {}
    }
})
const dataList = ref([])
onMounted(() => {
    getInit()
    read()
})

const getInit = async () => {
   
    let param;
    if(JSON.stringify(route.query)!== '{}'){
        param = route.query
    }
    else{
        param  = props.paramsData
    }
    let res = await Api.notice.detail.post(param);
    if (res.code == '200') {
        form.value = res.data
        dataList.value = res.dataList
    }

}
const read = async() =>{
    let param;
    if(JSON.stringify(route.query)!== '{}'){
        param = route.query
    }
    else{
        param  = props.paramsData
    }
    let res = await Api.notice.read.post(param)
    if (res.code == 200) {
		getMsgCount()
	}
}
const getMsgCount = async () => {
	let res = await authApi.msgCount.post()
    console.log(res)
	if (res.code == 200) {
		store.commit("SET_msgCount", res.totalRows);
	}
}
const operClick = (item) => {
    window.open(item.fileFullPath)
}
</script>
<style scoped>
.ts-text {
    max-width: 80%;
    margin: 0 auto;
}

.ts-text h1 {
    text-align: center;
    font-size: 38px;
    font-weight: 500;
    line-height: 46px;
    margin: 5px auto 15px auto;
}

.ts-text h4 {
    text-align: center;
    margin: 15px 0 5px 0;
    font-size: 25px;
    color: #999;
}

.channel {
    text-align: center;
    margin-top: 31px;
    font-size: 15px;
    color: #666;
}

.content {}
.link-type,.link-type:focus {
    color: #337ab7;
    cursor: pointer;
}

.link-type:focus:hover,.link-type:hover {
    color: #20a0ff
}
</style>